home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
9-Digit Zip Code Directory
/
9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO
/
z4src.zip
/
BSHALT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-11
|
4KB
|
129 lines
//----------------------------------------------------------------------------
// MODULE DESCRIPTION
//
// Module: bshalt.c
// Title: Base library
// Notice: John M. Weeder
// Copyright (c) 1993. All rights reserved.
// This module contains proprietary information and should be
// treated as confidential.
//
//----------------------------------------------------------------------------
// MAINTENANCE HISTORY
//
// $Workfile$
// $Revision$
// $Author$
// $Date$
// $Log$
//
//----------------------------------------------------------------------------
// MODULE NARRATIVE
//
//
// This module contains code to halt an application on a serious error.
// No clean-up is done. The application is simply terminated!
//
// The code in this module should be written entirely in C.
// Do not use any C++ constructs.
//
// This module is portable to:
// DOS 3.X+
// MS Windows 3.X+
// OS/2 2.X+
// OS/2 2.0 PM
// SCO UNIX.
//
// The following compilers are supported:
// MSC 6.0A
// MSC/C++ 7.0
// Borland C++ 3.1 for DOS
// Borland C++ 1.0 for OS/2 2.X
// SCO UNIX cc
//
//----------------------------------------------------------------------------
#include <bs.h>
//----------------------------------------------------------------------------
// Description: Display a VERY serious fatal error message.
// Text is written to stdout and program aborts with
// no clean-up
// Program aborts with exit code 99.
// Parameters: pcsz Error message text
// Returns: FALSE
//----------------------------------------------------------------------------
BOOL FN_E Halt_Debug(PCSZ pcsz)
{
FILE *fileLog = fopen("halt.log", "a+t");
CHAR szContext[IOBUF_SIZE];
SIZET i;
if (!pcsz)
pcsz = "Unknown fatal internal application error.";
if (fileLog != NULL)
{
DebugContext(szContext, TRUE);
fprintf(fileLog,
"%s"
"Program Halted!\n"
"%s\n",
szContext, pcsz);
fclose(fileLog);
}
DebugContext(szContext, FALSE);
#if OS_WINDOWS
strcat(szContext, pcsz);
MessageBox(NULL, szContext, "HALT !", MB_ICONEXCLAMATION|MB_OK|MB_TASKMODAL);
#elif OS_PM
#else
fprintf(stderr,
"\n"
"%s"
"Program Halted!\n%s\n"
"\n",
szContext, pcsz);
#endif
for (i = 3; i < 100; ++i) // Brute force method of closing all files.
close(i);
#if OS_DOS && COMPILER_BORLAND
CtrlCTerminate();
PrintScreenTerminate();
CritErrTerminate();
#endif
_exit(99);
#if COMPILER_BORLAND && OS_DOS
_asm { // Simply KILL the program. No more clean-up
mov ax, 4CFFh // or anything
int 21h
}
#endif
return FALSE;
}
//----------------------------------------------------------------------------
// Description: Run standard test suite
// Parameters: sTest Test to run.
// 0 Run all default tests (except).
// Default is 0.
// Returns: TRUE if successful.
//----------------------------------------------------------------------------
#if COMPILE_TEST
BOOL FN HaltTest(SHORT sTest)
{
NOTUSED(sTest);
Halt("This is a test error");
return TRUE;
}
#endif
//----------------------------------------------------------------------------
//------------------------------- End of File --------------------------------
//----------------------------------------------------------------------------